﻿
using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DBUtility;

namespace XQ.SP.DalServices
{
    //检查详细
    public partial class UserInfoCheckDal : BaseDal
    {

        public bool ExistsWhere(string whereSql)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from UserInfoCheck");
            if (whereSql != "")
            {
                strSql.Append(" where " + whereSql);
            }

            return DbHelperSQL.Exists(strSql.ToString());
        }
        public bool Exists(long id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [UserInfoCheck]");
            strSql.Append(" where  [Id]=@Id ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = id;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }

        // 大批量导入数据
        public bool BulkCopy(DataTable data, string batchNo, int batchSize = 5000, bool onlyUpdate = false, int timeout = 300)
        {
            #region

            var sql = @"
CREATE TABLE UserInfoCheck_import
(
	No         NVARCHAR (60),
	Citys      NVARCHAR (60),
	Towns      NVARCHAR (60),
	Village    NVARCHAR (60),
	Name       NVARCHAR (60),
	Sex        NVARCHAR (60),
	UID        NVARCHAR (60),
	Nation     NVARCHAR (60),
	ZhiYe      NVARCHAR (60),
	HunYing    NVARCHAR (60),
	WenHua     NVARCHAR (60),
	ShangHu    NVARCHAR (60),
	BuNaRu     NVARCHAR (60),
	YiNian     NVARCHAR (60),
	CanJiaTi   NVARCHAR (60),
	CanJiaJian NVARCHAR (60),
	CanJiaTime DATETIME,
	JieGuo     NVARCHAR (60),
	JIWang     NVARCHAR (60),
	CaiXue     NVARCHAR (60),
	FuCha      NVARCHAR (60),
	JieGuoHIV  NVARCHAR (60),
	WeiJianCe  NVARCHAR (60),
	[Desc]     NVARCHAR (200),
	State      NVARCHAR (40),
	StateTime  DATETIME,
	Id         BIGINT IDENTITY NOT NULL,
	Status     INT,
	Creator    BIGINT,
	Created    DATETIME,
	Modifier   BIGINT,
	Modified   DATETIME,
	Images     NVARCHAR (200),
	BatchNo    VARCHAR (20),
	Change     TINYINT NOT NULL,
	IsShangHu  NVARCHAR (50)
)
";
            //if (DbHelperSQL.ExecuteSql(sql) == 0)
            //{
            //    return false;
            //}

            #endregion

            if (!DbHelperSQL.BulkCopy("UserInfoCheck_import", data, batchSize, timeout))
            {
                return false;
            }

            var sql1 = @"

-- 复制表内重复
INSERT INTO UserInfoCheck_Repeat (
No,Citys,Towns,Village,Name,Sex,UID,Nation,ZhiYe,HunYing,WenHua,ShangHu,BuNaRu,YiNian,CanJiaTi,CanJiaJian,CanJiaTime,JieGuo,JIWang,CaiXue,FuCha,JieGuoHIV,WeiJianCe,[Desc],State,StateTime,Status,Creator,Created,Modifier,Modified,Images,BatchNo,Change,IsShangHu 
)
SELECT No,Citys,Towns,Village,Name,Sex,UID,Nation,ZhiYe,HunYing,WenHua,ShangHu,BuNaRu,YiNian,CanJiaTi,CanJiaJian,CanJiaTime,JieGuo,JIWang,CaiXue,FuCha,JieGuoHIV,WeiJianCe,[Desc],State,StateTime,Status,Creator,Created,Modifier,Modified,Images,BatchNo,Change,IsShangHu 
FROM UserInfoCheck_import 
WHERE UID IN (
	SELECT UID FROM UserInfoCheck_import 
	WHERE BatchNo='{0}' GROUP BY UID HAVING count(1)>1
)

-- 在正式库中已经存在的临时数据
INSERT INTO UserInfoCheck_Repeat (
No,Citys,Towns,Village,Name,Sex,UID,Nation,ZhiYe,HunYing,WenHua,ShangHu,BuNaRu,YiNian,CanJiaTi,CanJiaJian,CanJiaTime,JieGuo,JIWang,CaiXue,FuCha,JieGuoHIV,WeiJianCe,[Desc],State,StateTime,Status,Creator,Created,Modifier,Modified,Images,BatchNo,Change,IsShangHu 
)
SELECT A.No,A.Citys,A.Towns,A.Village,A.Name,A.Sex,A.UID,A.Nation,A.ZhiYe,A.HunYing,A.WenHua,A.ShangHu,A.BuNaRu,A.YiNian,A.CanJiaTi,A.CanJiaJian,A.CanJiaTime,A.JieGuo,A.JIWang,A.CaiXue,A.FuCha,A.JieGuoHIV,A.WeiJianCe,A.[Desc],A.State,A.StateTime,A.Status,A.Creator,A.Created,A.Modifier,A.Modified,A.Images,A.BatchNo,A.Change,A.IsShangHu 
FROM UserInfoCheck_import A
INNER JOIN UserInfoCheck B on A.UID = B.UID AND A.BatchNo='{0}'
WHERE A.Citys<>B.Citys OR A.Towns<>B.Towns OR A.Village<>B.Village 


-- 删除表内重复
DELETE UserInfoCheck_import 
WHERE UID IN (
	SELECT UID FROM UserInfoCheck_import 
	WHERE BatchNo='{0}' GROUP BY UID HAVING count(1)>1
) AND Id NOT IN (
	SELECT min(Id) FROM UserInfoCheck_import 
	WHERE BatchNo='{0}' GROUP BY UID HAVING count(1)>1
)

-- 删除正式库已经存在的临时数据
DELETE B FROM UserInfoCheck_import B
INNER JOIN UserInfoCheck A on A.UID = B.UID AND B.BatchNo='{0}'
WHERE A.Citys<>B.Citys OR A.Towns<>B.Towns OR A.Village<>B.Village


UPDATE UserInfoCheck 
SET 
 Name       = B.Name      
,Sex        = B.Sex       
,UID        = B.UID       
,Nation     = B.Nation    
,ZhiYe      = B.ZhiYe     
,HunYing    = B.HunYing   
,WenHua     = B.WenHua    
,ShangHu    = B.ShangHu   
,BuNaRu     = B.BuNaRu    
,YiNian     = B.YiNian    
,CanJiaTi   = B.CanJiaTi  
--,CanJiaJian = B.CanJiaJian
--,CanJiaTime = B.CanJiaTime
--,JieGuo     = B.JieGuo    
--,JIWang     = B.JIWang    
,CaiXue     = B.CaiXue    
,FuCha      = B.FuCha     
,JieGuoHIV  = B.JieGuoHIV 
,WeiJianCe  = B.WeiJianCe 
,[Desc]     = B.[Desc]    
,State      = B.State     
,StateTime  = B.StateTime 
,Status     = B.Status
,Modifier   = B.Modifier  
,Modified   = B.Modified   
,BatchNo    = B.BatchNo   
,Change     = 2    
,IsShangHu  = B.IsShangHu 
FROM UserInfoCheck A
INNER JOIN UserInfoCheck_import B on A.UID = B.UID
WHERE (A.Modified<=B.Modified OR A.Modified IS NULL) AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village AND B.BatchNo='{0}'

UPDATE UserInfoCheck 
SET CanJiaJian = B.CanJiaJian
FROM UserInfoCheck A
INNER JOIN UserInfoCheck_import B on A.UID = B.UID
WHERE (A.Modified<=B.Modified OR A.Modified IS NULL) AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village 
AND (B.CanJiaJian IS NOT NULL AND B.CanJiaJian<>'' AND len(B.CanJiaJian)>0) AND B.BatchNo='{0}'
--AND A.CanJiaJian<>'是'

UPDATE UserInfoCheck 
SET CanJiaTime = B.CanJiaTime
FROM UserInfoCheck A
INNER JOIN UserInfoCheck_import B on A.UID = B.UID
WHERE (A.Modified<=B.Modified OR A.Modified IS NULL) AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village 
AND B.CanJiaTime IS NOT NULL AND B.BatchNo='{0}'
--AND A.CanJiaJian<>'是'

UPDATE UserInfoCheck 
SET 
JieGuo     = B.JieGuo   
FROM UserInfoCheck A
INNER JOIN UserInfoCheck_import B on A.UID = B.UID
WHERE (A.Modified<=B.Modified OR A.Modified IS NULL) AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village 
AND (B.JieGuo IS NOT NULL AND B.JieGuo<>'' AND len(B.JieGuo)>0) AND B.BatchNo='{0}'
--AND A.CanJiaJian<>'是'

UPDATE UserInfoCheck 
SET JIWang     = B.JIWang 
FROM UserInfoCheck A
INNER JOIN UserInfoCheck_import B on A.UID = B.UID
WHERE (A.Modified<=B.Modified OR A.Modified IS NULL) AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village 
AND (B.JIWang IS NOT NULL AND B.JIWang<>'' AND len(B.JIWang)>0) AND B.BatchNo='{0}'
--AND A.CanJiaJian<>'是'

";
            // 是否插入新数据
            if (!onlyUpdate)
            {
                sql1 += @"

INSERT INTO UserInfoCheck 
(
No        
,Citys     
,Towns     
,Village   
,Name      
,Sex       
,UID       
,Nation    
,ZhiYe     
,HunYing   
,WenHua    
,ShangHu   
,BuNaRu    
,YiNian    
,CanJiaTi  
,CanJiaJian
,CanJiaTime
,JieGuo    
,JIWang    
,CaiXue    
,FuCha     
,JieGuoHIV 
,WeiJianCe 
,[Desc]    
,State     
,StateTime 
,Status    
,Creator   
,Created
,Images    
,BatchNo   
,Change    
,IsShangHu 
)
SELECT No        
,Citys     
,Towns     
,Village   
,Name      
,Sex       
,UID       
,Nation    
,ZhiYe     
,HunYing   
,WenHua    
,ShangHu   
,BuNaRu    
,YiNian    
,CanJiaTi  
,CanJiaJian
,CanJiaTime
,JieGuo    
,JIWang    
,CaiXue    
,FuCha     
,JieGuoHIV 
,WeiJianCe 
,[Desc]    
,State     
,StateTime 
,Status    
,Creator   
,getdate()
,Images    
,BatchNo   
,1    
,IsShangHu 
FROM UserInfoCheck_import B WHERE NOT EXISTS (SELECT 1 FROM UserInfoCheck A WHERE A.UID=B.UID AND A.Citys=B.Citys AND A.Towns=B.Towns AND A.Village=B.Village) AND B.BatchNo='{0}'

";
            }

            if (DbHelperSQL.ExecuteSql(string.Format(sql1, batchNo)) == 0)
            {
                //return false;  // 当前逻辑可能不更新数据
            }
            return true;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(XQ.SP.Model.UserInfoCheckItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [UserInfoCheck](");
            strSql.Append("[No],[Citys],[Towns],[Village],[Name],[Sex],[UID],[Nation],[ZhiYe],[HunYing],[WenHua],[ShangHu],[BuNaRu],[YiNian],[CanJiaTi],[CanJiaJian],[JieGuo],[JIWang],[CaiXue],[FuCha],[JieGuoHIV],[WeiJianCe],[Desc],[State],[Status],[Creator],[Created],[Modifier],[Modified],[Images],[Change]");

            if (model.CanJiaTime > DateTime.MinValue)
            {
                strSql.Append(",[CanJiaTime]");
            }
            if (model.StateTime > DateTime.MinValue)
            {
                strSql.Append(",[StateTime]");
            }

            strSql.Append(") values (");
            strSql.Append("@No,@Citys,@Towns,@Village,@Name,@Sex,@UID,@Nation,@ZhiYe,@HunYing,@WenHua,@ShangHu,@BuNaRu,@YiNian,@CanJiaTi,@CanJiaJian,@JieGuo,@JIWang,@CaiXue,@FuCha,@JieGuoHIV,@WeiJianCe,@Desc,@State,@Status,@Creator,@Created,@Modifier,@Modified,@Images,@Change");

            if (model.CanJiaTime > DateTime.MinValue)
            {
                strSql.Append(",@CanJiaTime");
            }
            if (model.StateTime > DateTime.MinValue)
            {
                strSql.Append(",@StateTime");
            }

            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");

            var parameters = new List<SqlParameter>(){
			            new SqlParameter("@No", SqlDbType.NVarChar,120){Value=model.No} ,            
			            new SqlParameter("@Citys", SqlDbType.NVarChar,120){Value=model.Citys} ,            
			            new SqlParameter("@Towns", SqlDbType.NVarChar,120){Value=model.Towns} ,            
			            new SqlParameter("@Village", SqlDbType.NVarChar,120){Value=model.Village} ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,120){Value=model.Name} ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,120){Value=model.Sex} ,            
			            new SqlParameter("@UID", SqlDbType.NVarChar,120){Value=model.UID} ,            
			            new SqlParameter("@Nation", SqlDbType.NVarChar,120){Value=model.Nation} ,            
			            new SqlParameter("@ZhiYe", SqlDbType.NVarChar,120){Value=model.ZhiYe} ,            
			            new SqlParameter("@HunYing", SqlDbType.NVarChar,120){Value=model.HunYing} ,            
			            new SqlParameter("@WenHua", SqlDbType.NVarChar,120){Value=model.WenHua} ,                  
			            new SqlParameter("@ShangHu", SqlDbType.NVarChar,120){Value=model.ShangHu} ,            
			            new SqlParameter("@BuNaRu", SqlDbType.NVarChar,120){Value=model.BuNaRu} ,            
			            new SqlParameter("@YiNian", SqlDbType.NVarChar,120){Value=model.YiNian} ,            
			            new SqlParameter("@CanJiaTi", SqlDbType.NVarChar,120){Value=model.CanJiaTi} ,            
			            new SqlParameter("@CanJiaJian", SqlDbType.NVarChar,120){Value=model.CanJiaJian} ,            
			            //new SqlParameter("@CanJiaTime", SqlDbType.DateTime,8){Value=model.CanJiaTime} ,            
			            new SqlParameter("@JieGuo", SqlDbType.NVarChar,120){Value=model.JieGuo} ,            
			            new SqlParameter("@JIWang", SqlDbType.NVarChar,120){Value=model.JiWang} ,            
			            new SqlParameter("@CaiXue", SqlDbType.NVarChar,120){Value=model.CaiXue} ,            
			            new SqlParameter("@FuCha", SqlDbType.NVarChar,120){Value=model.FuCha} ,            
			            new SqlParameter("@JieGuoHIV", SqlDbType.NVarChar,120){Value=model.JieGuoHIV} ,            
			            new SqlParameter("@WeiJianCe", SqlDbType.NVarChar,120){Value=model.WeiJianCe} ,            
			            new SqlParameter("@Desc", SqlDbType.NVarChar,400){Value=model.Desc} ,            
			            new SqlParameter("@State", SqlDbType.NVarChar,80){Value=model.State} ,            
			            //new SqlParameter("@StateTime", SqlDbType.DateTime,8){Value=model.StateTime} ,            
			            new SqlParameter("@Status", SqlDbType.Int,4){Value=model.Status} ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8){Value=model.Creator} ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8){Value=model.Created} ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8){Value=model.Modifier} ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8){Value=model.Modified} ,            
			            new SqlParameter("@Images", SqlDbType.NVarChar,400){Value=model.Images} ,              
			            new SqlParameter("@Change", SqlDbType.TinyInt,1){Value=model.Change} ,           
            };

            if (model.CanJiaTime > DateTime.MinValue)
            {
                parameters.Add(new SqlParameter("@CanJiaTime", SqlDbType.DateTime, 8) { Value = model.CanJiaTime });
            }
            if (model.StateTime > DateTime.MinValue)
            {
                parameters.Add(new SqlParameter("@StateTime", SqlDbType.DateTime, 8) { Value = model.StateTime });
            }


            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters.ToArray());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt64(obj);
            }

        }

        /// <summary>
        ///   批量添加数据
        /// </summary>
        public int AddList(List<XQ.SP.Model.UserInfoCheckItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            foreach (XQ.SP.Model.UserInfoCheckItem model in models)
            {
                CommandInfo command = new CommandInfo();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into [UserInfoCheck](");
                strSql.Append("[No],[Citys],[Towns],[Village],[Name],[Sex],[UID],[Nation],[ZhiYe],[HunYing],[WenHua],[ShangHu],[BuNaRu],[YiNian],[CanJiaTi],[CanJiaJian],[CanJiaTime],[JieGuo],[JIWang],[CaiXue],[FuCha],[JieGuoHIV],[WeiJianCe],[Desc],[State],[StateTime],[Status],[Creator],[Created],[Modifier],[Modified],[Images]");
                strSql.Append(") values (");
                strSql.Append("@No,@Citys,@Towns,@Village,@Name,@Sex,@UID,@Nation,@ZhiYe,@HunYing,@WenHua,@ShangHu,@BuNaRu,@YiNian,@CanJiaTi,@CanJiaJian,@CanJiaTime,@JieGuo,@JIWang,@CaiXue,@FuCha,@JieGuoHIV,@WeiJianCe,@Desc,@State,@StateTime,@Status,@Creator,@Created,@Modifier,@Modified,@Images");
                strSql.Append(") ");
                strSql.Append(";select @@IDENTITY");

                SqlParameter[] parameters = {
			            new SqlParameter("@No", SqlDbType.NVarChar,120){Value=model.No} ,            
			            new SqlParameter("@Citys", SqlDbType.NVarChar,120){Value=model.Citys} ,            
			            new SqlParameter("@Towns", SqlDbType.NVarChar,120){Value=model.Towns} ,            
			            new SqlParameter("@Village", SqlDbType.NVarChar,120){Value=model.Village} ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,120){Value=model.Name} ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,120) {Value=model.Sex},            
			            new SqlParameter("@UID", SqlDbType.NVarChar,120){Value=model.UID} ,            
			            new SqlParameter("@Nation", SqlDbType.NVarChar,120){Value=model.Nation} ,            
			            new SqlParameter("@ZhiYe", SqlDbType.NVarChar,120){Value=model.ZhiYe} ,            
			            new SqlParameter("@HunYing", SqlDbType.NVarChar,120){Value=model.HunYing} ,            
			            new SqlParameter("@WenHua", SqlDbType.NVarChar,120){Value=model.WenHua} ,              
			            new SqlParameter("@ShangHu", SqlDbType.NVarChar,120){Value=model.ShangHu} ,            
			            new SqlParameter("@BuNaRu", SqlDbType.NVarChar,120){Value=model.BuNaRu} ,            
			            new SqlParameter("@YiNian", SqlDbType.NVarChar,120) {Value=model.YiNian},            
			            new SqlParameter("@CanJiaTi", SqlDbType.NVarChar,120) {Value=model.CanJiaTi},            
			            new SqlParameter("@CanJiaJian", SqlDbType.NVarChar,120){Value=model.CanJiaJian} ,            
			            new SqlParameter("@CanJiaTime", SqlDbType.DateTime,8){Value=model.CanJiaTime} ,            
			            new SqlParameter("@JieGuo", SqlDbType.NVarChar,120){Value=model.JieGuo} ,            
			            new SqlParameter("@JIWang", SqlDbType.NVarChar,120){Value=model.JiWang} ,            
			            new SqlParameter("@CaiXue", SqlDbType.NVarChar,120) {Value=model.CaiXue},            
			            new SqlParameter("@FuCha", SqlDbType.NVarChar,120){Value=model.FuCha} ,            
			            new SqlParameter("@JieGuoHIV", SqlDbType.NVarChar,120) {Value=model.JieGuoHIV},            
			            new SqlParameter("@WeiJianCe", SqlDbType.NVarChar,120) {Value=model.WeiJianCe},            
			            new SqlParameter("@Desc", SqlDbType.NVarChar,400){Value=model.Desc} ,            
			            new SqlParameter("@State", SqlDbType.NVarChar,80){Value=model.State} ,            
			            new SqlParameter("@StateTime", SqlDbType.DateTime,8) {Value=model.StateTime},            
			            new SqlParameter("@Id", SqlDbType.BigInt,8){Value=model.Id} ,            
			            new SqlParameter("@Status", SqlDbType.Int,4){Value=model.Status} ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8){Value=model.Creator} ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8){Value=model.Created} ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8){Value=model.Modifier} ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) {Value=model.Modified},            
			            new SqlParameter("@Images", SqlDbType.NVarChar,400) {Value=model.Images},            
            };

                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }
            object obj = DbHelperSQL.ExecuteSqlTran(commands);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }


        /// <summary>
        /// 批量更新数据
        /// </summary>
        public int UpdateList(List<XQ.SP.Model.UserInfoCheckItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            CommandInfo command = new CommandInfo();

            foreach (XQ.SP.Model.UserInfoCheckItem model in models)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update [UserInfoCheck] set ");

                strSql.Append(" [No] = @No,");
                strSql.Append(" [Citys] = @Citys,");
                strSql.Append(" [Towns] = @Towns,");
                strSql.Append(" [Village] = @Village,");
                strSql.Append(" [Name] = @Name,");
                strSql.Append(" [Sex] = @Sex,");
                strSql.Append(" [UID] = @UID,");
                strSql.Append(" [Nation] = @Nation,");
                strSql.Append(" [ZhiYe] = @ZhiYe,");
                strSql.Append(" [HunYing] = @HunYing,");
                strSql.Append(" [WenHua] = @WenHua,");
                strSql.Append(" [ShangHu] = @ShangHu,");
                strSql.Append(" [BuNaRu] = @BuNaRu,");
                strSql.Append(" [YiNian] = @YiNian,");
                strSql.Append(" [CanJiaTi] = @CanJiaTi,");
                strSql.Append(" [CanJiaJian] = @CanJiaJian,");
                strSql.Append(" [CanJiaTime] = @CanJiaTime,");
                strSql.Append(" [JieGuo] = @JieGuo,");
                strSql.Append(" [JIWang] = @JIWang,");
                strSql.Append(" [CaiXue] = @CaiXue,");
                strSql.Append(" [FuCha] = @FuCha,");
                strSql.Append(" [JieGuoHIV] = @JieGuoHIV,");
                strSql.Append(" [WeiJianCe] = @WeiJianCe,");
                strSql.Append(" [Desc] = @Desc,");
                strSql.Append(" [State] = @State,");
                strSql.Append(" [StateTime] = @StateTime,");
                strSql.Append(" [Status] = @Status,");
                strSql.Append(" [Creator] = @Creator,");
                strSql.Append(" [Created] = @Created,");
                strSql.Append(" [Modifier] = @Modifier,");
                strSql.Append(" [Modified] = @Modified,");
                strSql.Append(" [Images] = @Images");
                strSql.Append(" where [Id]=@Id ");

                SqlParameter[] parameters = {
			            new SqlParameter("@No", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Citys", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Towns", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Village", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@UID", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Nation", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@ZhiYe", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@HunYing", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@WenHua", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@ShangHu", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@BuNaRu", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@YiNian", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@CanJiaTi", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@CanJiaJian", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@CanJiaTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@JieGuo", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@JIWang", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@CaiXue", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@FuCha", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@JieGuoHIV", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@WeiJianCe", SqlDbType.NVarChar,120) ,            
			            new SqlParameter("@Desc", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@State", SqlDbType.NVarChar,80) ,            
			            new SqlParameter("@StateTime", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Images", SqlDbType.NVarChar,400) ,            
            };

                parameters[0].Value = model.No;
                parameters[1].Value = model.Citys;
                parameters[2].Value = model.Towns;
                parameters[3].Value = model.Village;
                parameters[4].Value = model.Name;
                parameters[5].Value = model.Sex;
                parameters[6].Value = model.UID;
                parameters[7].Value = model.Nation;
                parameters[8].Value = model.ZhiYe;
                parameters[9].Value = model.HunYing;
                parameters[10].Value = model.WenHua;
                parameters[11].Value = model.ShangHu;
                parameters[12].Value = model.BuNaRu;
                parameters[13].Value = model.YiNian;
                parameters[14].Value = model.CanJiaTi;
                parameters[15].Value = model.CanJiaJian;
                parameters[16].Value = model.CanJiaTime;
                parameters[17].Value = model.JieGuo;
                parameters[18].Value = model.JiWang;
                parameters[19].Value = model.CaiXue;
                parameters[20].Value = model.FuCha;
                parameters[21].Value = model.JieGuoHIV;
                parameters[22].Value = model.WeiJianCe;
                parameters[23].Value = model.Desc;
                parameters[24].Value = model.State;
                parameters[25].Value = model.StateTime;
                parameters[26].Value = model.Id;
                parameters[27].Value = model.Status;
                parameters[28].Value = model.Creator;
                parameters[29].Value = model.Created;
                parameters[30].Value = model.Modifier;
                parameters[31].Value = model.Modified;
                parameters[32].Value = model.Images;
                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }

            int rows = DbHelperSQL.ExecuteSqlTran(commands);
            return rows;

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XQ.SP.Model.UserInfoCheckItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [UserInfoCheck] set ");

            strSql.Append(" [No] = @No,");
            strSql.Append(" [Citys] = @Citys,");
            strSql.Append(" [Towns] = @Towns,");
            strSql.Append(" [Village] = @Village,");
            strSql.Append(" [Name] = @Name,");
            strSql.Append(" [Sex] = @Sex,");
            strSql.Append(" [UID] = @UID,");
            strSql.Append(" [Nation] = @Nation,");
            strSql.Append(" [ZhiYe] = @ZhiYe,");
            strSql.Append(" [HunYing] = @HunYing,");
            strSql.Append(" [WenHua] = @WenHua,");
            strSql.Append(" [ShangHu] = @ShangHu,");
            strSql.Append(" [BuNaRu] = @BuNaRu,");
            strSql.Append(" [YiNian] = @YiNian,");
            strSql.Append(" [CanJiaTi] = @CanJiaTi,");
            strSql.Append(" [CanJiaJian] = @CanJiaJian,");
            strSql.Append(" [JieGuo] = @JieGuo,");
            strSql.Append(" [JIWang] = @JIWang,");
            strSql.Append(" [CaiXue] = @CaiXue,");
            strSql.Append(" [FuCha] = @FuCha,");
            strSql.Append(" [JieGuoHIV] = @JieGuoHIV,");
            strSql.Append(" [WeiJianCe] = @WeiJianCe,");
            strSql.Append(" [Desc] = @Desc,");
            strSql.Append(" [State] = @State,");
            strSql.Append(" [Status] = @Status,");
            strSql.Append(" [Creator] = @Creator,");
            strSql.Append(" [Modifier] = @Modifier,");
            strSql.Append(" [Change] = @Change,");

            if (!string.IsNullOrWhiteSpace(model.Images))
            {
                strSql.Append(" [Images] = @Images,");
            }

            var count = 0;
            if (model.CanJiaTime > DateTime.MinValue)
            {
                strSql.Append(" [CanJiaTime] = @CanJiaTime,");
                count++;
            }
            if (model.StateTime > DateTime.MinValue)
            {
                strSql.Append(" [StateTime] = @StateTime,");
                count++;
            }
            if (model.Created > DateTime.MinValue)
            {
                strSql.Append(" [Created] = @Created,");
                count++;
            }
            if (model.Modified > DateTime.MinValue)
            {
                strSql.Append(" [Modified] = @Modified,");
                count++;
            }
            if (count > 0)
                strSql.Remove(strSql.Length - 1, 1);

            strSql.Append(" where [Id]=@Id ");

            var parameters = new List<SqlParameter>(){
			            new SqlParameter("@No", SqlDbType.NVarChar,120){Value=model.No} ,            
			            new SqlParameter("@Citys", SqlDbType.NVarChar,120){Value=model.Citys} ,            
			            new SqlParameter("@Towns", SqlDbType.NVarChar,120){Value=model.Towns} ,            
			            new SqlParameter("@Village", SqlDbType.NVarChar,120){Value=model.Village} ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,120){Value=model.Name} ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,120) {Value=model.Sex},            
			            new SqlParameter("@UID", SqlDbType.NVarChar,120){Value=model.UID} ,            
			            new SqlParameter("@Nation", SqlDbType.NVarChar,120){Value=model.Nation} ,            
			            new SqlParameter("@ZhiYe", SqlDbType.NVarChar,120){Value=model.ZhiYe} ,            
			            new SqlParameter("@HunYing", SqlDbType.NVarChar,120){Value=model.HunYing} ,            
			            new SqlParameter("@WenHua", SqlDbType.NVarChar,120){Value=model.WenHua} ,              
			            new SqlParameter("@ShangHu", SqlDbType.NVarChar,120){Value=model.ShangHu} ,            
			            new SqlParameter("@BuNaRu", SqlDbType.NVarChar,120){Value=model.BuNaRu} ,            
			            new SqlParameter("@YiNian", SqlDbType.NVarChar,120) {Value=model.YiNian},            
			            new SqlParameter("@CanJiaTi", SqlDbType.NVarChar,120) {Value=model.CanJiaTi},            
			            new SqlParameter("@CanJiaJian", SqlDbType.NVarChar,120){Value=model.CanJiaJian} ,            
			            //new SqlParameter("@CanJiaTime", SqlDbType.DateTime,8){Value=model.CanJiaTime} ,            
			            new SqlParameter("@JieGuo", SqlDbType.NVarChar,120){Value=model.JieGuo} ,            
			            new SqlParameter("@JIWang", SqlDbType.NVarChar,120){Value=model.JiWang} ,            
			            new SqlParameter("@CaiXue", SqlDbType.NVarChar,120) {Value=model.CaiXue},            
			            new SqlParameter("@FuCha", SqlDbType.NVarChar,120){Value=model.FuCha} ,            
			            new SqlParameter("@JieGuoHIV", SqlDbType.NVarChar,120) {Value=model.JieGuoHIV},            
			            new SqlParameter("@WeiJianCe", SqlDbType.NVarChar,120) {Value=model.WeiJianCe},            
			            new SqlParameter("@Desc", SqlDbType.NVarChar,400){Value=model.Desc} ,            
			            new SqlParameter("@State", SqlDbType.NVarChar,80){Value=model.State} ,            
			            //new SqlParameter("@StateTime", SqlDbType.DateTime,8) {Value=model.StateTime},            
			            new SqlParameter("@Id", SqlDbType.BigInt,8){Value=model.Id} ,            
			            new SqlParameter("@Status", SqlDbType.Int,4){Value=model.Status} ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8){Value=model.Creator} ,            
			            //new SqlParameter("@Created", SqlDbType.DateTime,8){Value=model.Created} ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8){Value=model.Modifier} ,            
			            //new SqlParameter("@Modified", SqlDbType.DateTime,8) {Value=model.Modified},            
			            //new SqlParameter("@Images", SqlDbType.NVarChar,400) {Value=model.Images},           
			            new SqlParameter("@Change", SqlDbType.NVarChar,400) {Value=model.Change},  // 修改标志                 
            };

            if (!string.IsNullOrWhiteSpace(model.Images))
            {
                parameters.Add(new SqlParameter("@Images", SqlDbType.NVarChar, 400) { Value = model.Images });
            }

            if (model.CanJiaTime > DateTime.MinValue)
                parameters.Add(new SqlParameter("@CanJiaTime", SqlDbType.DateTime, 8) { Value = model.CanJiaTime });
            if (model.StateTime > DateTime.MinValue)
                parameters.Add(new SqlParameter("@StateTime", SqlDbType.DateTime, 8) { Value = model.StateTime });
            if (model.Created > DateTime.MinValue)
                parameters.Add(new SqlParameter("@Created", SqlDbType.DateTime, 8) { Value = model.Created });
            if (model.Modified > DateTime.MinValue)
                parameters.Add(new SqlParameter("@Modified", SqlDbType.DateTime, 8) { Value = model.Modified });

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters.ToArray());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateByUid(XQ.SP.Model.UserInfoCheckItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [UserInfoCheck] set ");

            strSql.Append(" [No] = @No,");
            strSql.Append(" [Citys] = @Citys,");
            strSql.Append(" [Towns] = @Towns,");
            strSql.Append(" [Village] = @Village,");
            strSql.Append(" [Name] = @Name,");
            strSql.Append(" [Sex] = @Sex,");
            //strSql.Append(" [UID] = @UID,");
            strSql.Append(" [Nation] = @Nation,");
            strSql.Append(" [ZhiYe] = @ZhiYe,");
            strSql.Append(" [HunYing] = @HunYing,");
            strSql.Append(" [WenHua] = @WenHua,");
            strSql.Append(" [ShangHu] = @ShangHu,");
            strSql.Append(" [BuNaRu] = @BuNaRu,");
            strSql.Append(" [YiNian] = @YiNian,");
            strSql.Append(" [CanJiaTi] = @CanJiaTi,");
            strSql.Append(" [CanJiaJian] = @CanJiaJian,");
            strSql.Append(" [JieGuo] = @JieGuo,");
            strSql.Append(" [JIWang] = @JIWang,");
            strSql.Append(" [CaiXue] = @CaiXue,");
            strSql.Append(" [FuCha] = @FuCha,");
            strSql.Append(" [JieGuoHIV] = @JieGuoHIV,");
            strSql.Append(" [WeiJianCe] = @WeiJianCe,");
            strSql.Append(" [Desc] = @Desc,");
            strSql.Append(" [State] = @State,");
            strSql.Append(" [Status] = @Status,");
            strSql.Append(" [Creator] = @Creator,");
            strSql.Append(" [Modifier] = @Modifier,");
            strSql.Append(" [Images] = @Images,");
            strSql.Append(" [Change] = @Change,");
            var count = 0;
            if (model.CanJiaTime > DateTime.MinValue)
            {
                strSql.Append(" [CanJiaTime] = @CanJiaTime,");
                count++;
            }
            if (model.StateTime > DateTime.MinValue)
            {
                strSql.Append(" [StateTime] = @StateTime,");
                count++;
            }
            if (model.Created > DateTime.MinValue)
            {
                strSql.Append(" [Created] = @Created,");
                count++;
            }
            if (model.Modified > DateTime.MinValue)
            {
                strSql.Append(" [Modified] = @Modified,");
                count++;
            }
            if (count > 0)
                strSql.Remove(strSql.Length - 1, 1);

            strSql.Append(" where [UID]=@UID ");

            var parameters = new List<SqlParameter>(){
			            new SqlParameter("@No", SqlDbType.NVarChar,120){Value=model.No} ,            
			            new SqlParameter("@Citys", SqlDbType.NVarChar,120){Value=model.Citys} ,            
			            new SqlParameter("@Towns", SqlDbType.NVarChar,120){Value=model.Towns} ,            
			            new SqlParameter("@Village", SqlDbType.NVarChar,120){Value=model.Village} ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,120){Value=model.Name} ,            
			            new SqlParameter("@Sex", SqlDbType.NVarChar,120) {Value=model.Sex},            
			            new SqlParameter("@UID", SqlDbType.NVarChar,120){Value=model.UID} ,            
			            new SqlParameter("@Nation", SqlDbType.NVarChar,120){Value=model.Nation} ,            
			            new SqlParameter("@ZhiYe", SqlDbType.NVarChar,120){Value=model.ZhiYe} ,            
			            new SqlParameter("@HunYing", SqlDbType.NVarChar,120){Value=model.HunYing} ,            
			            new SqlParameter("@WenHua", SqlDbType.NVarChar,120){Value=model.WenHua} ,              
			            new SqlParameter("@ShangHu", SqlDbType.NVarChar,120){Value=model.ShangHu} ,            
			            new SqlParameter("@BuNaRu", SqlDbType.NVarChar,120){Value=model.BuNaRu} ,            
			            new SqlParameter("@YiNian", SqlDbType.NVarChar,120) {Value=model.YiNian},            
			            new SqlParameter("@CanJiaTi", SqlDbType.NVarChar,120) {Value=model.CanJiaTi},            
			            new SqlParameter("@CanJiaJian", SqlDbType.NVarChar,120){Value=model.CanJiaJian} ,            
			            //new SqlParameter("@CanJiaTime", SqlDbType.DateTime,8){Value=model.CanJiaTime} ,            
			            new SqlParameter("@JieGuo", SqlDbType.NVarChar,120){Value=model.JieGuo} ,            
			            new SqlParameter("@JIWang", SqlDbType.NVarChar,120){Value=model.JiWang} ,            
			            new SqlParameter("@CaiXue", SqlDbType.NVarChar,120) {Value=model.CaiXue},            
			            new SqlParameter("@FuCha", SqlDbType.NVarChar,120){Value=model.FuCha} ,            
			            new SqlParameter("@JieGuoHIV", SqlDbType.NVarChar,120) {Value=model.JieGuoHIV},            
			            new SqlParameter("@WeiJianCe", SqlDbType.NVarChar,120) {Value=model.WeiJianCe},            
			            new SqlParameter("@Desc", SqlDbType.NVarChar,400){Value=model.Desc} ,            
			            new SqlParameter("@State", SqlDbType.NVarChar,80){Value=model.State} ,            
			            //new SqlParameter("@StateTime", SqlDbType.DateTime,8) {Value=model.StateTime},            
			            new SqlParameter("@Id", SqlDbType.BigInt,8){Value=model.Id} ,            
			            new SqlParameter("@Status", SqlDbType.Int,4){Value=model.Status} ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8){Value=model.Creator} ,            
			            //new SqlParameter("@Created", SqlDbType.DateTime,8){Value=model.Created} ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8){Value=model.Modifier} ,            
			            //new SqlParameter("@Modified", SqlDbType.DateTime,8) {Value=model.Modified},            
			            new SqlParameter("@Images", SqlDbType.NVarChar,400) {Value=model.Images},           
			            new SqlParameter("@Change", SqlDbType.NVarChar,400) {Value=model.Change},  // 修改标志                 
            };

            if (model.CanJiaTime > DateTime.MinValue)
                parameters.Add(new SqlParameter("@CanJiaTime", SqlDbType.DateTime, 8) { Value = model.CanJiaTime });
            if (model.StateTime > DateTime.MinValue)
                parameters.Add(new SqlParameter("@StateTime", SqlDbType.DateTime, 8) { Value = model.StateTime });
            if (model.Created > DateTime.MinValue)
                parameters.Add(new SqlParameter("@Created", SqlDbType.DateTime, 8) { Value = model.Created });
            if (model.Modified > DateTime.MinValue)
                parameters.Add(new SqlParameter("@Modified", SqlDbType.DateTime, 8) { Value = model.Modified });

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters.ToArray());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from UserInfoCheck ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.BigInt) };
            parameters[0].Value = Id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string Idlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from UserInfoCheck ");
            strSql.Append(" where Id in (" + Idlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteListByUid(string uidList)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from UserInfoCheck ");
            strSql.Append(" where UID in (" + uidList + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.UserInfoCheckItem GetModel(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from UserInfoCheck ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = Id;


            XQ.SP.Model.UserInfoCheckItem model = new XQ.SP.Model.UserInfoCheckItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {

                if (ds.Tables[0].Rows[0]["No"].ToString() != "")
                {
                    model.No = ds.Tables[0].Rows[0]["No"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Citys"].ToString() != "")
                {
                    model.Citys = ds.Tables[0].Rows[0]["Citys"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Towns"].ToString() != "")
                {
                    model.Towns = ds.Tables[0].Rows[0]["Towns"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Village"].ToString() != "")
                {
                    model.Village = ds.Tables[0].Rows[0]["Village"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UID"].ToString() != "")
                {
                    model.UID = ds.Tables[0].Rows[0]["UID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Nation"].ToString() != "")
                {
                    model.Nation = ds.Tables[0].Rows[0]["Nation"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ZhiYe"].ToString() != "")
                {
                    model.ZhiYe = ds.Tables[0].Rows[0]["ZhiYe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HunYing"].ToString() != "")
                {
                    model.HunYing = ds.Tables[0].Rows[0]["HunYing"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WenHua"].ToString() != "")
                {
                    model.WenHua = ds.Tables[0].Rows[0]["WenHua"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ShangHu"].ToString() != "")
                {
                    model.ShangHu = ds.Tables[0].Rows[0]["ShangHu"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BuNaRu"].ToString() != "")
                {
                    model.BuNaRu = ds.Tables[0].Rows[0]["BuNaRu"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YiNian"].ToString() != "")
                {
                    model.YiNian = ds.Tables[0].Rows[0]["YiNian"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaTi"].ToString() != "")
                {
                    model.CanJiaTi = ds.Tables[0].Rows[0]["CanJiaTi"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaJian"].ToString() != "")
                {
                    model.CanJiaJian = ds.Tables[0].Rows[0]["CanJiaJian"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaTime"].ToString() != "")
                {
                    model.CanJiaTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["CanJiaTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JieGuo"].ToString() != "")
                {
                    model.JieGuo = ds.Tables[0].Rows[0]["JieGuo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JIWang"].ToString() != "")
                {
                    model.JiWang = ds.Tables[0].Rows[0]["JIWang"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaiXue"].ToString() != "")
                {
                    model.CaiXue = ds.Tables[0].Rows[0]["CaiXue"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FuCha"].ToString() != "")
                {
                    model.FuCha = ds.Tables[0].Rows[0]["FuCha"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JieGuoHIV"].ToString() != "")
                {
                    model.JieGuoHIV = ds.Tables[0].Rows[0]["JieGuoHIV"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WeiJianCe"].ToString() != "")
                {
                    model.WeiJianCe = ds.Tables[0].Rows[0]["WeiJianCe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Desc"].ToString() != "")
                {
                    model.Desc = ds.Tables[0].Rows[0]["Desc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = ds.Tables[0].Rows[0]["State"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StateTime"].ToString() != "")
                {
                    model.StateTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["StateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Images"].ToString() != "")
                {
                    model.Images = ds.Tables[0].Rows[0]["Images"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.UserInfoCheckItem GetModelWhereStr(string whereStr)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from UserInfoCheck ");
            if (whereStr != "")
            {
                strSql.Append(" where " + whereStr);
            }

            XQ.SP.Model.UserInfoCheckItem model = new XQ.SP.Model.UserInfoCheckItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {

                if (ds.Tables[0].Rows[0]["No"].ToString() != "")
                {
                    model.No = ds.Tables[0].Rows[0]["No"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Citys"].ToString() != "")
                {
                    model.Citys = ds.Tables[0].Rows[0]["Citys"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Towns"].ToString() != "")
                {
                    model.Towns = ds.Tables[0].Rows[0]["Towns"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Village"].ToString() != "")
                {
                    model.Village = ds.Tables[0].Rows[0]["Village"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = ds.Tables[0].Rows[0]["Sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UID"].ToString() != "")
                {
                    model.UID = ds.Tables[0].Rows[0]["UID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Nation"].ToString() != "")
                {
                    model.Nation = ds.Tables[0].Rows[0]["Nation"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ZhiYe"].ToString() != "")
                {
                    model.ZhiYe = ds.Tables[0].Rows[0]["ZhiYe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HunYing"].ToString() != "")
                {
                    model.HunYing = ds.Tables[0].Rows[0]["HunYing"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WenHua"].ToString() != "")
                {
                    model.WenHua = ds.Tables[0].Rows[0]["WenHua"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ShangHu"].ToString() != "")
                {
                    model.ShangHu = ds.Tables[0].Rows[0]["ShangHu"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BuNaRu"].ToString() != "")
                {
                    model.BuNaRu = ds.Tables[0].Rows[0]["BuNaRu"].ToString();
                }
                if (ds.Tables[0].Rows[0]["YiNian"].ToString() != "")
                {
                    model.YiNian = ds.Tables[0].Rows[0]["YiNian"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaTi"].ToString() != "")
                {
                    model.CanJiaTi = ds.Tables[0].Rows[0]["CanJiaTi"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaJian"].ToString() != "")
                {
                    model.CanJiaJian = ds.Tables[0].Rows[0]["CanJiaJian"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CanJiaTime"].ToString() != "")
                {
                    model.CanJiaTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["CanJiaTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["JieGuo"].ToString() != "")
                {
                    model.JieGuo = ds.Tables[0].Rows[0]["JieGuo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JIWang"].ToString() != "")
                {
                    model.JiWang = ds.Tables[0].Rows[0]["JIWang"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CaiXue"].ToString() != "")
                {
                    model.CaiXue = ds.Tables[0].Rows[0]["CaiXue"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FuCha"].ToString() != "")
                {
                    model.FuCha = ds.Tables[0].Rows[0]["FuCha"].ToString();
                }
                if (ds.Tables[0].Rows[0]["JieGuoHIV"].ToString() != "")
                {
                    model.JieGuoHIV = ds.Tables[0].Rows[0]["JieGuoHIV"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WeiJianCe"].ToString() != "")
                {
                    model.WeiJianCe = ds.Tables[0].Rows[0]["WeiJianCe"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Desc"].ToString() != "")
                {
                    model.Desc = ds.Tables[0].Rows[0]["Desc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = ds.Tables[0].Rows[0]["State"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StateTime"].ToString() != "")
                {
                    model.StateTime = System.DateTime.Parse(ds.Tables[0].Rows[0]["StateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Images"].ToString() != "")
                {
                    model.Images = ds.Tables[0].Rows[0]["Images"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM UserInfoCheck ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" * ");
            strSql.Append(" FROM UserInfoCheck ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }


        /// <summary>
        /// 获得身份证列表
        /// </summary>
        public DataSet GetUidList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select UID ");
            strSql.Append(" FROM UserInfoCheck ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
    }
}

